package datastructure.doublylinkedlist;

/**
 * 
 * 
 * @author Lei
 */
public class RemoveValue {

    public static void removeValue(Node head, int value) {
        Node cur = head;
        while (cur != null) {
            if (cur.value == value) {
                if (cur.prev != null) {
                    cur.prev.next = cur.next;
                }
                if (cur.next != null) {
                    cur.next.prev = cur.prev;
                }
                break;
            }
            cur = cur.next;

        }
    }
}
